-
-
Notifications
You must be signed in to change notification settings - Fork 52
Handle metadata discovery at creation of AudioObjects #793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Oowoosh0
wants to merge
3
commits into
elementary:main
Choose a base branch
from
Oowoosh0:metadata-in-audioobject
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| [SingleInstance] | ||
| public class Music.MetadataDiscoverer : Object { | ||
| private Gst.PbUtils.Discoverer discoverer; | ||
| private HashTable<string, AudioObject> objects_to_update; | ||
|
|
||
| construct { | ||
| try { | ||
| discoverer = new Gst.PbUtils.Discoverer ((Gst.ClockTime) (5 * Gst.SECOND)); | ||
| discoverer.discovered.connect (relay_metadata); | ||
| discoverer.finished.connect (discoverer.stop); | ||
| } catch (Error e) { | ||
| critical ("Unable to start Gstreamer Discoverer: %s", e.message); | ||
| } | ||
| objects_to_update = new HashTable<string, AudioObject> (str_hash, str_equal); | ||
| } | ||
|
|
||
| public void request (AudioObject audio) { | ||
| objects_to_update.insert (audio.uri, audio); | ||
| discoverer.start (); | ||
| discoverer.discover_uri_async (audio.uri); | ||
| } | ||
|
|
||
| private void relay_metadata (Gst.PbUtils.DiscovererInfo info, Error? err) { | ||
| string uri = info.get_uri (); | ||
| var audio_obj = objects_to_update.get (uri); | ||
| objects_to_update.remove (uri); | ||
| switch (info.get_result ()) { | ||
| case Gst.PbUtils.DiscovererResult.URI_INVALID: | ||
| critical ("Couldn't read metadata for '%s': invalid URI.", uri); | ||
| return; | ||
| case Gst.PbUtils.DiscovererResult.ERROR: | ||
| critical ("Couldn't read metadata for '%s': %s", uri, err.message); | ||
| return; | ||
| case Gst.PbUtils.DiscovererResult.TIMEOUT: | ||
| critical ("Couldn't read metadata for '%s': Discovery timed out.", uri); | ||
| return; | ||
| case Gst.PbUtils.DiscovererResult.BUSY: | ||
| critical ("Couldn't read metadata for '%s': Already discovering a file.", uri); | ||
| return; | ||
| case Gst.PbUtils.DiscovererResult.MISSING_PLUGINS: | ||
| critical ("Couldn't read metadata for '%s': Missing plugins.", uri); | ||
| return; | ||
| default: | ||
| break; | ||
| } | ||
|
|
||
| audio_obj.update_metadata (info); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These properties are all publicly settable so why do this here instead of in the MetadataDiscoverer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this probably should be moved into the MetadataDiscoverer. Sorry I didn't have much time the last 2 weeks, but I'll have a lot more time from wednesday onward to update this.