Merge branch 'master' into Ocarina-next

Conflicts:
	Sconstruct
	tests/Sconscript
This commit is contained in:
Anna Schumaker 2014-06-26 17:00:09 -04:00
commit 77616aa8d2
10 changed files with 38 additions and 19 deletions

9
DESIGN
View File

@ -529,7 +529,8 @@ Tag Database:
Track *tagdb :: add_track(const std::string &filepath, Library *library);
Add a new track to the track_db and return a pointer to it.
Return NULL if this track is already in the database.
Return NULL if this track is already in the database or if
there is an error when tagging.
Library *tagdb :: add_library(const std::string &filepath);
Add a new path to library_db. Return a pointer to the new path
@ -758,7 +759,7 @@ Track Tag:
void read(File &);
void write(File &);
void tag();
bool tag();
const std::string path();
void played();
bool less_than(Track *, sort_t);
@ -793,7 +794,7 @@ Track Tag:
void write(File &f);
Write track information to file.
void Track :: tag();
bool Track :: tag();
Use TagLib to find tags and audio properties for this file.
- Insert Artist, Album, and Genre into their databases and
@ -802,6 +803,8 @@ Track Tag:
- Set play_count, last_year, last_month and last_day = 0.
- Set lowercase title and find the string form of length.
Return true if the track could be tagged and false otherwise.
const std::string Track :: path();
Combine library->path and filepath to find the full path to
the audio file.

View File

@ -1,6 +1,6 @@
# Maintainer: Anna Schumaker <anna@ocarinaproject.net>
pkgname=ocarina
pkgver=6.1
pkgver=6.1.1
pkgrel=1
pkgdesc="A simple GTK and gstreamer based music player."
url="http://www.ocarinaproject.net/"
@ -13,7 +13,7 @@ conflicts=()
replaces=()
backup=()
source=("http://ocarinaproject.net/wp-content/ocarina/${pkgname}-${pkgver}.tar.gz")
sha1sums=('af56a0d391251033ebc35406ed75c8e7d56c307e')
sha1sums=('7fa6275aeba85b86988b5a3c88bafc7c6e36ec88')
build() {
cd "${srcdir}/${pkgname}-${pkgver}"

View File

@ -165,7 +165,8 @@ Track :: Track(const std::string &f, Library *l)
Track :: ~Track()
{
library->count--;
if (library)
library->count--;
}
const std::string Track :: primary_key() const
@ -232,15 +233,16 @@ static T *find_or_insert(const T &tag, Database<T> &db)
return ret;
}
void Track :: tag()
bool Track :: tag()
{
TagLib :: Tag *tag;
TagLib :: AudioProperties *audio;
TagLib :: FileRef ref(path().c_str(), true, TagLib::AudioProperties::Fast);
library->count++;
if (ref.isNull()) {
print("ERROR: Could not read tags for file %s\n", path().c_str());
return;
print("WARNING: Could not read tags for file %s\n", path().c_str());
return false;
}
tag = ref.tag();
@ -259,7 +261,7 @@ void Track :: tag()
filter :: add(artist->name, id);
filter :: add(album->name, id);
library->count++;
return true;
}
const std::string Track :: path() const
@ -366,8 +368,10 @@ void tagdb :: commit_library()
Track *tagdb :: add_track(const std::string &filepath, Library *library)
{
Track *track = track_db.insert(Track(filepath, library));
if (track)
track->tag();
if (track && !track->tag()) {
remove_track(track->id);
track = NULL;
}
return track;
}

View File

@ -103,7 +103,7 @@ public:
void read(File &);
void write(File &);
void tag();
bool tag();
const std::string path() const;
void played();
int less_than(Track *, sort_t);

View File

@ -217,7 +217,7 @@
<object class="GtkWindow" id="o_window">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Ocarina 6.1</property>
<property name="title" translatable="yes">Ocarina 6.1.1</property>
<property name="default_width">1024</property>
<property name="default_height">683</property>
<child>

View File

@ -0,0 +1 @@
abcdefghijklmnopqrstuvwxyz

View File

@ -44,7 +44,7 @@ class OTest:
cmd = "%s | tee %s.out" % (path, path)
if test_env.Valgrind == True:
cmd = "%s %s" % (valgrind, cmd)
test = test_env.Command("%s.out" % self.Name, [], "set -x pipefail; %s" % cmd)
test = test_env.Command("%s.out" % self.Name, [], "set -x; set -o pipefail; %s" % cmd)
Depends(test, prog)
if (check_depends == True) and (OTest.Prev != None):

View File

@ -96,11 +96,20 @@ static void test_track(struct TagArgs *args)
test_not_equal(track->last_day, args->last_day);
}
static void test_invalid_track(Library *lib)
{
unsigned int library_size = lib->count;
Track *track = tagdb :: add_track("tests/Music/invalid_track", lib);
test_equal(track, TRACK_NULL);
test_equal(lib->count, library_size);
}
static void test_all_tracks()
{
struct TagArgs expected;
Library *library = tagdb :: add_library("tests/Music");
expected.library = tagdb :: add_library("tests/Music");
expected.library = library;
expected.full_path = "tests/Music/1.ogg";
expected.artist = "Artist";
expected.artist_lower = "artist";
@ -176,6 +185,8 @@ static void test_all_tracks()
expected.filepath = "666.ogg";
expected.length_str = "11:06";
run_test("Tags Track Test (666.ogg)", test_track, &expected);
run_test("Tags Track Test (Invalid)", test_invalid_track, library);
}
static void test_comparison()

View File

@ -5,9 +5,9 @@
#include <tests/test.h>
#ifdef CONFIG_DEBUG
const std::string expected = "6.1-debug";
const std::string expected = "6.2-debug";
#else
const std::string expected = "6.1";
const std::string expected = "6.2";
#endif /* CONFIG_DEBUG */
static void test_version()

View File

@ -18,7 +18,7 @@ function tag_file()
mkdir -p /tmp/ocarina/dir{1..5}
for i in $(seq 5); do
cp tests/Music/* /tmp/ocarina/dir$i/
cp tests/Music/*.ogg /tmp/ocarina/dir$i/
for f in /tmp/ocarina/dir$i/*; do
tag_file $f $i