Determine Mounted Media & System Id


kool65

Still Fresh
Joined
Sep 11, 2008
Messages
27
Location
Sydney, Australia
Website
linux.kewley.name
Hi,

I'm currently writing a basic media player for use in the car with touchscreen capability. I'm writing this in C++ and SDL and is basically my first C++ project.

A couple of questions :-

1) What is the best way (or is there a standard way) to determine what the removable media paths are (ie /media/mmcxxx). I want to do an initial search for the music directory. As a start I have found that I can do "mount | grep media | grep dev", does someone have a better way?

2) Since I'm running this also on a desktop linux box I would like the program to determine that it is running on the pandora.

Something like this would probably work...

if (FileExists("/pandora/appdata/op_lcdsettings")) {
// Running on Pandora
} else {
// Running on other
}

Is there a better way?
 
kool65 said:
1) What is the best way (or is there a standard way) to determine what the removable media paths are (ie /media/mmcxxx). I want to do an initial search for the music directory. As a start I have found that I can do "mount | grep media | grep dev", does someone have a better way?
I'd probably just walk through the directories in /media looking for a "music" subdirectory.

2) Since I'm running this also on a desktop linux box I would like the program to determine that it is running on the pandora.

Something like this would probably work...

if (FileExists("/pandora/appdata/op_lcdsettings")) {
// Running on Pandora
} else {
// Running on other
}

Is there a better way?
Would conditional compilation do?
 
Last edited by a moderator:
Depending on your needs, you might be able o get away with adjusting to _features_, not machines.

Same as for web coding -- it is usually bad to ask 'is this IE? firefox? what version?', and instead say 'does this browser have Canvas?'

So likewise.. check that the screen res has sufficient space to render your UI (or adjust your UI), and just go; if it has a dpad, use it.. but if not, fail gracefully.

The pandora is more or less like othe rlinux boxes, so you probably don't need to say 'are you a pandora?' .. but at the same time, sometimes you do need to do that.

So for you.. what makes you need to know if its a pandora or not?

jeff
 
SteveM said:
I'd probably just walk through the directories in /media looking for a "music" subdirectory.

Yeah that makes sense, I'll just do that, I'll look for "music" and "Music", if not found then I'll have to pop up a selection box.

SteveM said:
Would conditional compilation do?


I'd prefer not to use conditional compilation if possible


skeezix said:
The pandora is more or less like othe rlinux boxes, so you probably don't need to say 'are you a pandora?' .. but at the same time, sometimes you do need to do that.
So for you.. what makes you need to know if its a pandora or not?

jeff

I probably don't NEED to know it's a Pandora, my UI is designed to run at 800x480, I check the res of the system if it is 800x480 then I run full screen if not I run in a window. At the moment if I determine I'm running on the Pandora I disable the mouse pointer (as it has touchscreen) and scan for music on removable media. If it's not a Pandora then I look for music in $HOME/{M|m}usic and use a standard mouse pointer as most desktop systems don't have a touchscreen. I suppose it would just work anyway even if I didn't detect it being a Pandora and looked in both places. I was thinking about more specific stuff like auto screen dim/blanking etc, battery level and such, for which there are scripts on the Pandora, so if they are there then I guess I assume Pandora and use them. I will generate a 'conf' file so the user can adjust the settings if necessary, so far I have musicdir={path} and touchscreen={yes|no}.

I guess my goal is to have the app do most of the config itself and not bug the user unless absolutely necessary. I'm probably over thinking this :)
 
Last edited by a moderator:
kool65 said:
I'd prefer not to use conditional compilation if possible
Yeah, doesn't seem to fit at all well in this case.

I guess my goal is to have the app do most of the config itself and not bug the user unless absolutely necessary. I'm probably over thinking this :)
Your users will thank you ;-) I think your approach is the right one; just check all possible locations and if you find something, use it. The /media/* thing isn't even Pandora-specific - a lot of Linux desktops use the same mount points for removable media. Definitely use a config file to allow adding to and/or overriding what the app's detected, maybe even for supplying hints to the detection mechanism.
 
Last edited by a moderator:
If anyone is interested I finally released an Alpha version of the above mentioned media player, see it here http://linux.kewley.name/minamp or at http://dl.openhandhelds.org/cgi-bin/pandora.cgi?0,0,0,0,6,399
 
Back
Top